2026-01-19

Administration

Slides

Use Canvas

Lecture Schedule (always in HB)

Labs

2 types of labs:

There are 3 morning labs at 8 am. These will have some TAs online for people who do not want to wake up in the mornings.

Demos

A poll will be posted on the appropriate lab page before each deadline. Register the day before the demos. About 5 minutes, online during the digital lab-passes. Be there 10 minutes ahead of schedule.

Assignments

Register your group before Friday!

  1. Trainspotting (Java)
  2. A-mazed (Java)
  3. CCHAT (Erlang)

Wednesday Lab

There is a lab on Wednesday:

Code Grader

Using a new system for grading labs in Canvas.

May have issues, please have patience.

Questions

Post your technical questions on the discussion forum.

Administrative/personal issues: pcp-teachers@lists.chalmers.se

DO NOT use Canvas messages.

Learning outcomes

See Learning outcomes on Chalmers website.

Three parts

The course is divided into 3 parts:

Part 1: Classic, shared-memory concurrency in Java:

Part 2: Message passing concurrency

Part 3: Lock-free programming

Tutorials

Java Tutorial

Assumes you know Java, introducing Java concurrency.

21 January

Erlang Tutorial

Does not assume you know Erlang.

13 February

Material

Exam

Open-book exam:

All topics in the lectures can be examined (except guest lectures). See exams previous years on Canvas.

Date: 2026-03-20
Reexam: August/October 2026 (format changed to digital)

Check Canvas for updates.

Computers

Install Java and Erlang/OTP on your computer.

Try out the examples from the lectures.

Lab 1 works best on Linux.

Course Evaluation

Please respond!

Introduction to Concurrent Programming

Slides

Amdahl's Law

With n processors than can run in parallel, how much speedup can we achieve?

speedup=sequential execution timeparellel execution time

Amdahl's law shows that the impact of introducing parallelism is limited by the fraction p of a program that can be parallelized:

maximum speedup=1(1p)+pn

Goals

Processes

Independent unit of execution. A sequential program with an independent:

Runtime/OS schedules and tells processors to work on a process.

States

Ready: ready to be run and allocated
Blocked: waiting for external event
Running: currently running on a processor

process-state.png

Threads

For Java we will use Threads which are lightweight processes. Communicates with other processes with shared (global) memory.

In Java, represented as a class with the following methods:

start() // Start a thread
run() // Entry point for a new thread
join() // Wait for a thread to end
isAlive() // Check if thread is RUNNING
setName()
getName()
getPriority()
Implementation using the Thread class and inheritance

Extend the Thread class and override the run() method. (Javadoc)

Not recommended.

Implementation using Runnable

The Runnable interface (Javadoc) implements just the run() method and a Thread can be created from the runnable.

Runnable myRun = new MyRunnable();
Thread myThread = new Thread(myRun);
myThread.start();

Message passing

In Erlang there is no shared memory, instead messages are sent between processes.